package com.example.basic.web.controller.newly;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.basic.core.result.Result;
import com.example.basic.core.result.ResultGenerator;
import com.example.basic.utils.IdUtils;
import com.example.basic.web.mapper.newly.SysBacklogMapper;
import com.example.basic.web.model.basicData.BasicData;
import com.example.basic.web.model.newly.SysBacklog;
import com.example.basic.web.response.UserBacklogVo;
import com.example.basic.web.service.newly.ISysBacklogService;
import com.example.basic.web.webSocket.WebSocketServerUtil;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

import static com.example.basic.web.service.newly.impl.SysPdaFlowServiceImpl.FLOW_STATUS_NO;

/**
 * 【请填写功能名称】Controller
 * 
 * @author zhiyun
 * @date 2025-08-08
 */
@RestController
@RequestMapping("/api/v1/byg/backlog")
public class SysBacklogController
{
    @Autowired
    private ISysBacklogService sysBacklogService;
    @Autowired
    private SysBacklogMapper sysBacklogMapper;

    //待办列表
    @GetMapping("/queryList")
    public Result<List<UserBacklogVo>> list(
            @ApiParam(value = "userId",name = "userId",required = false) @RequestParam(required = false) String userId){
        return ResultGenerator.genSuccessResult(sysBacklogService.queryList(userId));
    }

    //测试
    @GetMapping("/cs")
    public Result<Boolean> cs(){
//        addBacklog(sysPdaFlow.getId(), "02c5ffff-15a0-4291-8581-00a2d08f232a");
        SysBacklog sysBacklog = new SysBacklog();
        sysBacklog.setFlowId("df1d1ca4-f64a-406b-a9e2-360555f9f0fa");
        sysBacklog.setSysUserId("02c5ffff-15a0-4291-8581-00a2d08f232a");
        sysBacklog.setCreateAt(new Date());
        sysBacklog.setUpdateAt(new Date());
        sysBacklog.setStatus(FLOW_STATUS_NO);
        sysBacklog.setId(IdUtils.fastUUID());
        sysBacklogMapper.insert(sysBacklog);
        WebSocketServerUtil.sendInfo("来新任务了", "02c5ffff-15a0-4291-8581-00a2d08f232a");
        return ResultGenerator.genSuccessResult(true);
    }

}
